#{extends 'main_cliente.html' /} 
#{set title:'Produtos' /}



<div id="result">
</div>

<script type="text/javascript" charset="${_response_encoding}">

    // Rebuild state
    $('#search').val(sessvars.search)    
    if(sessvars.page == undefined) {
        sessvars.page = 1
    }


    $('#size option[value='+sessvars.size+']').attr('selected', 'true')
    
    // Search function
    var search = function() {
        sessvars.search = $('#search').val()
         sessvars.size = $('#size').val() 
        var listAction = #{jsAction @listaProdutosClienteLoop(':search', 6, ':page') /} 
        $('#result').load(listAction({search: sessvars.search, size: sessvars.size, page: sessvars.page}), function() {
            $('#content').css('visibility', 'visible')
        })
    }
    
    // Events handler
    $('#submit').click(function() { 

        sessvars.page = 1
        search()
    })
    $('#search').keyup(function() {
        sessvars.page = 1
        search()
    })
    $('#nextPage').live('click', function(e) {
        sessvars.page = $(this).attr('href')
        e.preventDefault()
        search()        
    })
    $('#downPage').live('click', function(e) {
        sessvars.page = $(this).attr('href')
        e.preventDefault()
        search()        
    }) 
    
    // Init
        $('#content').css('visibility', 'hidden')
        search()
    
</script>	
	

